home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / misc_pto / bmacs / markword.cb < prev    next >
Text File  |  1991-03-19  |  780b  |  41 lines

  1. //
  2. //   mark_word_at_cursor         by Luigi M. Bianchi  03/19/91
  3. //
  4. //   expects: nothing
  5. //   returns: nothing
  6. //
  7. //   marks word at cursor; displays error message if there is no word
  8. //
  9. //   a word is defined here as any combination of [_A-Za-z0-9]
  10. //   not starting with a digit
  11.  
  12.  
  13. void mark_word_at_cursor ()
  14.  
  15. {
  16.     int col1, col2;
  17.     int gotit;
  18.    string word;
  19.  
  20.     gotit = search_back ("[ \t]|[~A-Za-z_]");
  21.     if (gotit)
  22.         next_char (1);
  23.     else
  24.         move_abs(NULL,1);
  25.     inq_position (NULL,col1);
  26.  
  27.     search_fwd ("[ \n\t]|[~0-9A-Za-z_]");
  28.     prev_char (1);
  29.     inq_position (NULL, col2);
  30.  
  31.     word = trim (read (col2 - col1 + 1));
  32.     if (word == "")
  33.         error("No word at cursor");
  34.     else
  35.         {
  36.         move_abs (NULL, col1);
  37.         drop_anchor(1);
  38.         move_abs(NULL,col2);
  39.         }
  40. }
  41.